<template>
	<view class="vip-bg">
		<view class="title-page">
			<view :style="{ height: statusBarHeight }" class="uni-status-bar">
			</view>
			<view class="title-block">
				<image :src="leftIcon" @tap="leftClick" class="left-img"></image>
				<view class="title-center">
					成为会员
				</view>
			</view>
		</view>
		<view :style="{height:statusBarHeightTwo}"></view>
		<!-- <view class="item-lst"> -->
		<scroll-view scroll-x="true" class="kite-classify-scroll">
			<block v-for="(item,index) in lst" :key="index">
				<view class="item" style="display: inline-block">

					<image :src="item.image" class="img"></image>

					<view class="txt" :class="indexCurrent==index?'select-txt-color':''">
						{{item.title}}
					</view>
				</view>
			</block>
		</scroll-view>
		<!-- </view> -->
		<swiper class="swiper" circular :autoplay="false" :current='indexCurrent' @change='swiperChange'
			next-margin="38rpx" previous-margin="38rpx">
			<swiper-item v-for="(item,index) in lst">
				<view class="vip-open">
					<view class="members-top">
						<image :src="membersTop"></image>
					</view>
					<view class="vip-title">
						{{item.title}}
					</view>
					<view class="ul-block">

						<view class="li-line" v-for="explain in item.explain">
							<view class="circle-span"></view>
							<view class="li-txt"> {{explain}}</view>
						</view>
					</view>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectetTitle: '积分当钱花',
				indexCurrent: 0,
				bangIcon: require('@/static/my/bangIcon.png'),
				membersTop: require('@/static/vip/membersTop.png'),
				userInfo: {},
				obj: {},
				topImgLeft: 'left:44rpx',
				itemLst: [{
						title: '积分当钱花',
						// img: require('@/static/vip/members1.png'),
					},
					{
						title: '每月运费券',
						// img: require('@/static/vip/members2.png'),
					},
					{
						title: '眼镜享9折',
						// img: require('@/static/vip/members3.png'),
					},
					{
						title: '省钱无忧购',
						// img: require('@/static/vip/members4.png'),
					}
				],
				list: [],
				schedule: 0,
				statusBarHeight: 20,
				statusBarHeightTwo: 20,
				leftIcon: require('@/static/vip/left-icon.png'),
				leaveImg: require('@/static/vip/leave/leave1.png'),
				lst: [],
			}
		},
		onLoad() {
			let obj = uni.getStorageSync('vipInfo')
			
			
			for (var i = 0; i < obj.vip_explain.length; i++) {
				
				
				var explain = obj.vip_explain[i].explain.split("－")
				
				obj.vip_explain[i].explain = explain;
				
			}
			
			
			this.lst = obj.vip_explain
			
			console.log(this.lst )
			
			
			
			
			
			
			this.userInfo = uni.getStorageSync("userInfo")
		},
		onShow() {
			this.userInfo = uni.getStorageSync('userInfo')
		},
		mounted() {
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
			this.statusBarHeightTwo = (uni.getSystemInfoSync().statusBarHeight + 44) + 'px'
		},
		methods: {
			getSchedule() {
				var schedule = 100 / this.list[this.indexCurrent].integral;
				return schedule;
			},
			leftClick() {
				uni.navigateBack()
			},
			getVipName() {
				var name = "普通用户"
				for (var i = 0; i < this.list.length; i++) {
					if (this.userInfo.integral > this.list[i].integral) {
						name = this.list[i].vip_name
					}
				}
				return name;
			},
			getUserVipList() {
				var self = this;
				//商品分类获取	
				uni.request({
					url: self.serviceUrl + '/app-yytc-backstage/getUserVipList',
					method: "GET",
					success: (res) => {
						if (res.data.code == 200) {
							var list = res.data.data.list;
							console.log(list)
							for (var i = 0; i < list.length; i++) {
								if (list[i].vip_explain) {
									list[i].vip_explain = JSON.parse(list[i].vip_explain)
								} else {
									list[i].vip_explain = []
								}
							}
							self.list = list;
							self.initProgress()
						}
					},
					fail() {

					}
				})
				//商品分类获取				
			},
			init() {
				var self = this;
				this.$http('common.userVipList').then(res => {
					var list = res.data.list;
					for (var i = 0; i < list.length; i++) {
						if (list[i].vip_explain) {
							list[i].vip_explain = JSON.parse(list[i].vip_explain)
						} else {
							list[i].vip_explain = []
						}
					}
					self.list = list;
					self.itemClick(0)
				})
			},
			initProgress() {

			},
			itemClick(index) {
				this.indexCurrent = index
				if (this.indexCurrent == 0) {
					this.topImgLeft = 'left:44rpx'
				}
				if (this.indexCurrent == 1) {
					this.topImgLeft = 'left:232rpx'
				}
				if (this.indexCurrent == 2) {
					this.topImgLeft = 'right:232rpx'
				}
				if (this.indexCurrent == 3) {
					this.topImgLeft = 'right:44rpx'
				}

				var schedule = this.userInfo.integral / this.list[this.indexCurrent].integral * 100;
				if (schedule > 100) {
					schedule = 100;
				}
				this.schedule = schedule;
			},
			//充值页面
			topUpClick() {
				uni.navigateTo({
					url: '/pages/topUp/topUp'
				})
			},
			//邀请码
			shareClick() {
				uni.navigateTo({
					url: '/pages/promotion/promotion'
				})
			},
			swiperChange(e) {
				this.indexCurrent = e.detail.current
				this.changeLeaveImg(this.indexCurrent)

			},
			changeLeaveImg(index) {
				let leaveImg;
				switch (index) {
					case 0:
						leaveImg = require('@/static/vip/leave/leave1.png')
						break;
					case 1:
						leaveImg = require('@/static/vip/leave/leave2.png')
						break;
					case 2:
						leaveImg = require('@/static/vip/leave/leave3.png')
						break;
					case 3:
						leaveImg = require('@/static/vip/leave/leave4.png')
						break;
				}
				this.leaveImg = leaveImg
			},
			vipItemClick() {
				uni.navigateTo({
					url: '/pages/members/members'
				})
			}
		}
	}

</script>

<style lang="scss">
	.vip-bg {
		height: 100vh;
		width: 100%;
		background-image: url('@/static/vip/bg.png');
		background-repeat: no-repeat;
		background-size: 100% 100vh;
	}

	.kite-classify-scroll {
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		height: 140rpx;

	}

	.title-page {
		position: fixed;
		left: 0;
		right: 0;
		z-index: 999;

		.uni-status-bar {
			height: 20px;
		}

		.title-block {
			font-size: 32rpx;
			font-weight: 500;
			height: 80rpx;
			color: white;
			// color: rgba(0, 0, 0, 1);
			display: flex;
			align-items: center;

			.left-img {
				margin-left: 24rpx;
				width: 42rpx;
				height: 40rpx;
				flex: none;
			}

			.title-center {
				flex: auto;
				padding-right: 60rpx;
				// border: 1rpx solid red;
				width: 100%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

	}

	.item-lst {
		margin-top: 32rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;


	}

	.item {

		width: 25%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		text-align: center;

		.img {
			width: 68rpx;
			height: 68rpx;

		}

		.txt {
			margin-top: 20rpx;
			font-size: 24rpx;
			font-weight: 400;
			opacity: 0.7;
			color: rgba(255, 255, 255, 0.8);
		}

		.select-txt-color {
			opacity: 1;
		}
	}

	.swiper {
		margin-top: 40rpx;
		height: 1000rpx;

	}

	.vip-open {
		box-sizing: border-box;
		margin-top: 34rpx;
		margin-left: 24rpx;
		margin-right: 24rpx;
		padding-left: 24rpx;
		padding-right: 24rpx;
		height: 900rpx;
		background-repeat: no-repeat;
		background-size: 100% 900rpx;
		background-image: url('@/static/vip/membersBg.png');
		padding-bottom: 24rpx;
		border-radius: 36rpx;
		position: relative;

		.members-top {
			position: absolute;
			left: 0;
			right: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			top: 0;

			image {
				width: 326rpx;
				height: 78rpx;

			}
		}

		.vip-title {
			padding-top: 120rpx;
			box-sizing: border-box;
			font-size: 48rpx;
			font-weight: 500;
			color: rgba(0, 0, 0, 1);
			font-weight: bold;
			padding-bottom: 24rpx;
			border-bottom: 1rpx solid rgba(238, 238, 238, 0.9);
		}

		.ul-block {}

		.li-line {
			margin-top: 24rpx;
			display: flex;
			align-items: flex-start;
		}

		.circle-span {
			width: 12rpx;
			height: 12rpx;
			border-radius: 50%;
			background: rgba(0, 0, 0, 1);
			margin-top: 12rpx;
			margin-right: 14rpx;
		}

		.li-txt {

			line-height: 1.5em;
			font-size: 24rpx;
			font-weight: 400;
			color: rgba(102, 102, 102, 1);
		}
	}

	.vip-hint-txt {
		height: 770rpx;
		margin-right: 24rpx;
		margin-left: 24rpx;
		margin-top: 34rpx;
		border-radius: 8rpx;


		.hint-one-txt {
			padding-top: 24rpx;
			display: flex;
			align-items: center;

			.left-hint {
				width: 188rpx;
				height: 4rpx;
				background: linear-gradient(90deg, rgba(248, 230, 173, 0) 0%, rgba(248, 230, 173, 0.6) 100%);
				flex: none;
			}

			.txt {

				flex: auto;
				margin: 0 12rpx;
				color: #fff;
				font-size: 32rpx;
				font-weight: 600;
			}

			.right-hint {
				flex: none;
				width: 188rpx;
				height: 4rpx;
				background: linear-gradient(270deg, rgba(248, 230, 173, 0) 0%, rgba(248, 230, 173, 0.6) 100%);
			}
		}
	}

	.lst-block {
		display: flex;
		flex-wrap: wrap;
		margin-top: 32rpx;

		.item {
			width: 25%;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			padding: 24rpx;

			.item-img {
				width: 112rpx;
				height: 112rpx;
				background: rgba(245, 222, 195, 0.06);
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;

				.img {
					width: 56rpx;
					height: 66rpx;
				}
			}

			.item-txt {
				margin-top: 24rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.txt-one {
					font-size: 28rpx;
					font-weight: 700;
					line-height: 28rpx;
					color: rgba(255, 255, 255, 1);
				}

				.txt-two {
					font-size: 24rpx;
					font-weight: 400;
					line-height: 24rpx;
					color: rgba(248, 230, 173, 1);
					margin: 20rpx 0;
				}

				.txt-three {
					font-size: 24rpx;
					font-weight: 400;
					line-height: 24rpx;
					color: rgba(255, 255, 255, 0.3);

					span {
						color: rgba(248, 230, 173, 1);
						font-size: 24rpx;
						font-weight: 400;
					}
				}

				.txt-other {
					color: rgba(255, 255, 255, 0.3);
				}
			}
		}
	}

	.btn-block {
		margin-top: 30rpx;
		margin-left: 34rpx;
		margin-right: 34rpx;
		background-image: url('@/static/vip/btn/2.png');
		background-repeat: no-repeat;
		height: 88rpx;
		background-size: 100% 88rpx;
		bottom: 24rpx;
		position: fixed;
		left: 0;
		right: 0;

		.left-img {
			width: 50%;
			height: 100%;
			margin-left: -4rpx;
		}

		.txt-block {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			display: flex;
			align-items: center;

			.left-txt {
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				flex: 1;
				font-size: 28rpx;
				font-weight: 500;
				color: rgba(47, 41, 45, 1);
			}

			.right-txt {
				flex: 1;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 28rpx;
				font-weight: 500;
				color: rgba(255, 206, 147, 1);

			}
		}
	}

</style>

